#include <modules\system\system_interface.h>

namespace DelGE
{
	namespace Modules
	{
		namespace System
		{
			SystemInterface::SystemInterface()
			{
			}

			SystemInterface::~SystemInterface()
			{
			}

			SystemWindow* SystemInterface::CreateWindow(string sTitle, int iWidth, int iHeight, DelGESystemWindowStyle eStyle)
			{
				return new SystemWindow(sTitle, iWidth, iHeight, eStyle);
			}

			SystemTimer* SystemInterface::CreateTimer()
			{
				return new SystemTimer();
			}

			bool SystemInterface::IsVideoModeSupported(const SystemVideoMode &systemVideoMode)
			{
				vector<SystemVideoMode> lSupportedVideoModes;

				lSupportedVideoModes = this->GetSupportedVideoModes();

				if (find(lSupportedVideoModes.begin(), lSupportedVideoModes.end(), systemVideoMode) != lSupportedVideoModes.end())
					return true;
				else
					return false;
			}

			SystemVideoMode SystemInterface::FindNearestSupportedVideoMode(const SystemVideoMode &systemVideoMode)
			{
				SystemVideoMode nearestSupportedVideoMode;
				vector<SystemVideoMode> lSupportedVideoModes;

				lSupportedVideoModes = this->GetSupportedVideoModes();
				for (unsigned int i = 0; i < lSupportedVideoModes.size(); ++i)
				{
					nearestSupportedVideoMode = lSupportedVideoModes[i];
					if (nearestSupportedVideoMode >= systemVideoMode) break;
				}


				return nearestSupportedVideoMode;
			}
		}
	}
}